package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.Children;
import com.ruoyi.manage.service.IChildrenService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 儿童信息Controller
 * 
 * @author Admin
 * @date 2025-09-05
 */
@RestController
@RequestMapping("/manage/children")
public class ChildrenController extends BaseController
{
    @Autowired
    private IChildrenService childrenService;

    /**
     * 查询儿童信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:children:list')")
    @GetMapping("/list")
    public TableDataInfo list(Children children)
    {
        startPage();
        List<Children> list = childrenService.selectChildrenList(children);
        return getDataTable(list);
    }

    /**
     * 导出儿童信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:children:export')")
    @Log(title = "儿童信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Children children)
    {
        List<Children> list = childrenService.selectChildrenList(children);
        ExcelUtil<Children> util = new ExcelUtil<Children>(Children.class);
        util.exportExcel(response, list, "儿童信息数据");
    }

    /**
     * 获取儿童信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:children:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(childrenService.selectChildrenById(id));
    }

    /**
     * 新增儿童信息
     */
    @PreAuthorize("@ss.hasPermi('manage:children:add')")
    @Log(title = "儿童信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Children children)
    {
        return toAjax(childrenService.insertChildren(children));
    }

    /**
     * 修改儿童信息
     */
    @PreAuthorize("@ss.hasPermi('manage:children:edit')")
    @Log(title = "儿童信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Children children)
    {
        return toAjax(childrenService.updateChildren(children));
    }

    /**
     * 删除儿童信息
     */
    @PreAuthorize("@ss.hasPermi('manage:children:remove')")
    @Log(title = "儿童信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(childrenService.deleteChildrenByIds(ids));
    }
}
